package org.bling.star.server.service.impl;

import org.bling.star.common.model.UserInfo;
import org.bling.star.server.connect.GlobalPoolManager;
import org.bling.star.server.connect.node.InstanceConnection;
import org.bling.star.server.connect.node.TalkingStream;

import java.util.List;
import java.util.stream.Collectors;


public class StreamMessageService {
    public List<TalkingStream> talkingRoomList() {
        //return GlobalPoolManager.getAll();
        return null;
    }

    public List<UserInfo> roommateList(TalkingStream talkingStream) {
        List<UserInfo> collect = talkingStream.getConnectionGroup().stream().map(connectClient -> {
            InstanceConnection connection = (InstanceConnection) connectClient;
            return connection.getUserInfo();
        }).collect(Collectors.toList());
        return collect;
    }

    public TalkingStream talkingRoomInfo(String secretKey) {
        TalkingStream from = (TalkingStream) GlobalPoolManager.getFrom(secretKey);
        return from;
    }
}
